<!DOCTYPE html>
<html lang="zh">
<head>
	<th:block th:include="include :: header('卡片列表')" />

    <script th:src="@{/js/echarts.min.js}"></script>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-6">
                <div class="ibox">
                    <div class="ibox-title">
                        <span class="label label-primary pull-right">NEW</span>
                        <h5>男女生比例</h5>
                    </div>
                    <div class="ibox-content">
                        <div id="main1" style="width: 100%;height:400px;"></div>

                    </div>
                </div>
                <div class="ibox">
                    <div class="ibox-title">
                        <span class="label label-primary pull-right">NEW</span>
                        <h5>各系人数</h5>
                    </div>
                    <div class="ibox-content">
                        <div id="main2" style="width: 100%;height:400px;"></div>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="ibox">
                    <div class="ibox-title">
                        <span class="label label-primary pull-right">NEW</span>
                        <h5>各用人单位岗位数量</h5>
                    </div>
                    <div class="ibox-content">
                        <div id="main3" style="width: 100%;height:400px;"></div>

                    </div>
                </div>
                <div class="ibox">
                    <div class="ibox-title">
                        <span class="label label-primary pull-right">NEW</span>
                        <h5>工资结算比例</h5>
                    </div>
                    <div class="ibox-content">

                        <div id="main4" style="width: 100%;height:400px;"></div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
<script  type="text/javascript">
    //url
    var prefix = ctx + "workstudy/statistics/";
    // 基于准备好的dom，初始化echarts实例
    var myChart1 = echarts.init(document.getElementById('main1'));
    // 使用刚指定的配置项和数据显示图表。
    $.get(prefix+'selectUserBySumSex').done(function (data) {
        myChart1.setOption(
            {
                title: {
                    text: '男女生和总数比例',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                },
                series: [
                    {
                        name: '数量',
                        type: 'pie',
                        radius: '50%',
                        data: [
                            {value: data.male, name: '男'},
                            {value: data.female, name: '女'},
                            {value: data.total, name: '总数'},
                        ],
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            }
        );
    });

    //=============================================================================================

    var myChart2 = echarts.init(document.getElementById('main2'));
    // 使用刚指定的配置项和数据显示图表。
    $.get(prefix+'selectUserByDeptCount').done(function (data) {
        datalist=[];
        data.forEach(x=>{
            obj={value: x.count, name: x.deptName};
            datalist.push(obj);
        })
        console.log(datalist)
        myChart2.setOption(
            {
                title: {
                    text: '各系人数',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                },
                series: [
                    {
                        name: '数量',
                        type: 'pie',
                        radius: '50%',
                        data: datalist,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            }
        );
    });

    //=============================================================================================

    var myChart3 = echarts.init(document.getElementById('main3'));
    // 使用刚指定的配置项和数据显示图表。
    $.get(prefix+'selectWorkstudyAttendanceByCountRoleId').done(function (data) {
        datalist=[];
        data.forEach(x=>{
            obj={value: x.count, name: x.deptName};
            datalist.push(obj);
        })
        myChart3.setOption(
            {
                title: {
                    text: '各用人单位岗位数量',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                },
                series: [
                    {
                        name: '数量',
                        type: 'pie',
                        radius: '50%',
                        data: datalist,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            }
        );
    });

    //=============================================================================================

    var myChart4 = echarts.init(document.getElementById('main4'));
    // 使用刚指定的配置项和数据显示图表。
    $.get(prefix+'selectBySumSumprice').done(function (data) {
        myChart4.setOption(
            {
                title: {
                    text: '工资结算比例',
                    left: 'center'
                },
                color: ['#3398DB'],
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                        type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                    }
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        data: ['0-300', '301-600', '601-800', '800以上'],
                        axisTick: {
                            alignWithLabel: true
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ],
                series: [
                    {
                        name: '数量',
                        type: 'bar',
                        barWidth: '60%',
                        data: [data.count1,data.count2,data.count3,data.count4]
                    }
                ]
            }
        );
    });
</script>
</body>
</html>
